<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ include file="/includes/taglibs.jsp"%>
<%@ taglib uri="/WEB-INF/extremecomponents.tld" prefix="ec"%>
<%@ page import="com.cq.xjms.model.User"  %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>学生列表</title>
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/common.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/extremecomponents.css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.4.2.min.js"></script>
<style type="text/css">
	.eXtremeTable .tableHeader {
	height: 26px; 
	line-height:25px;
	background:url(/images/platform/tr.jpg) repeat;
	color: #000;
	font-weight: bold;
	border: 0px solid #CCC;
	background-image: url("/images/platform/tr1.jpg") no-repeat;
	background-position: top right;
	white-space: nowrap;
	overflow: hidden;
}
</style>
<script type="text/javascript">
	function del(id){
		window.location.href = "delStudent.action?student.id="+id;
	}
	function edit(id){
		window.location.href = "editStudent.action?student.id="+id;
	}
	function loadInstitute(){
		var action = "listInstitueJson.action";
		$("#instituteId").find("option").remove();
		$("#instituteId").append('<option value="">---请选择学院---</option>');
		var institudeId = "${clazz.department.institute.id}";
		$.getJSON(action,function(data){
			var json = eval(data);
			$.each(json,function(i,n){
				if(institudeId == json[i].id){
					$("#instituteId").append('<option selected value='+json[i].id+'>'+json[i].name+'</option>');
				}else{
					$("#instituteId").append('<option value='+json[i].id+'>'+json[i].name+'</option>');
				}
			}) 
		});
		if(institudeId!=""){
			selDepartment();
		}
	}
	function selDepartment(){
		var departmentId = "${clazz.department.id}";
		var id = "${clazz.department.institute.id}";
		if(id == ""){
			id = $("#instituteId").val();		
		}
		var action = "listDepartmentJson.action?institute.id="+id;
		$.getJSON(action,function(data){
			var json = eval(data);
			$.each(json,function(i,n){
				if(departmentId==json[i].id){
					$("#departmentId").append('<option selected value='+json[i].id+'>'+json[i].name+'</option>');
				}else{
					$("#departmentId").append('<option value='+json[i].id+'>'+json[i].name+'</option>');
				}
			})
		})
		if(departmentId!=""){
			selClass();
		}
	}
	
	function selClass(){
		var clazzId = "${clazz.id}";
		var id = "${clazz.department.id}";
		if(id == ""){
			id = $("#departmentId").val();			
		}
		var action = "listClazzJson.action?department.id="+id;
		$.getJSON(action,function(data){
			var json = eval(data);
			$.each(json,function(i,n){
				if(clazzId==json[i].id){
					$("#clazz").append('<option selected value='+json[i].id+'>'+json[i].name+'</option>');
				}else{
					$("#clazz").append('<option value='+json[i].id+'>'+json[i].name+'</option>');
				}
			})
		})
	}
</script>
<%
	Object obj = request.getSession().getAttribute("login_user");
 %>
</head>
	<body  onload="loadInstitute();">
		<div id="man_zone">
		<form action="listStudent.action" method="post" id="form1" >
		 <table class="table_style" border="0" align="center"  cellpadding="3" cellspacing="1" width="1000px">
		   	<tr>
		   		<td class="left_title_1">姓名:</td>
		   		<td>
		   		<input type="text" id="student.name" name="student.name" value="${student.name}"/>
		   		</td>
		   		<td class="left_title_1">学号:</td>
		   		<td>
		   		<input type="text" id="student.stuNo" name="student.stuNo" value="${student.stuNo}"/>
		   		</td>
		   		<td class="left_title_1">身份证:</td>
		   		<td>
		   		<input type="text" id="student.idcard" name="student.idcard" value="${student.idcard}"/>
		   		</td>
		   	</tr>	
		   	<tr>
		   		<td class="left_title_1">班级:</td>
		   		<td colspan="3">
				学院：<select id="instituteId" onchange="selDepartment();">
						<option>---请选择学院---</option>
						<s:iterator value="institutes">
							<option value="${id}">${name}</option>
						</s:iterator>
					</select>
				系：<select id="departmentId" onchange="selClass();">
						<option>---请选择系---</option>
					</select>
				班级：<select id="clazz" name="student.clazz.id">
						<option>---请选择班级---</option>
					</select>
		   		</td>	
		   		<td colspan="2"> <input type="submit" value="查询"/> </td>
		   	</tr>
		</table>
		</form>
		<ec:table retrieveRowsCallback="limit" cellspacing="1" filterable="false"   items="students" var="student" action="listStudent.action">
				<ec:row>
					<ec:column property="clazz.code" title="班级编号" width="10%"/>
					<ec:column property="clazz.name" title="班级" width="10%"/>
					<ec:column property="stuNo" title="学号" width="5%" />
					<ec:column property="name"  title="姓名" width="10%" />
					<ec:column property="sex"  title="性别" width="5%" >
					<s:if test="#attr.student.sex == 0">男</s:if>
					<s:if test="#attr.student.sex == 1">女</s:if>
					</ec:column>
					<ec:column property="tel" title="电话" width="10%"/>
					<ec:column property="phone" title="手机" width="10%" />
					<ec:column property="idcard" title="身份证" width="15%" />
					<ec:column property="birthdate" title="生日" width="10%">
						<s:date name="#attr.student.birthdate" format="yyyy-MM-dd" />
					</ec:column>
					<ec:column property="email" title="邮箱" width="15%"/>
					<%if(obj instanceof User){
					 %>
					<ec:column property="操作" sortable="false" 
						filterable="false" width="10%">
						
						<s:a href="###"
							onclick="edit('%{#attr.student.id}');">修改</s:a>
						<s:a href="###"
							onclick="del(%{#attr.student.id});">删除</s:a>
					</ec:column>
				    <%} %>	
				</ec:row>
				</ec:table>
		</div>
	</body>
</html>